package com.dun.re.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.dun.re.vo.User;

@Repository
public class LoginDAOImpl implements LoginDAO {
	private HibernateTemplate template;
	private Session session;

	/**
	 * getting session, template
	 * 
	 * @param sessionFactory
	 */

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.template = new HibernateTemplate(sessionFactory);
		this.session = this.template.getSessionFactory().openSession();
	}

	/**
	 * getting all users
	 */
	@SuppressWarnings("unchecked")
	public List<User> getUsers() {
		List<User> users = session.createCriteria(User.class).list();
		return users;
	}

}
